
package projForWen;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextPane;

/**
 *
 * @author Bacteria
 * Created on 2013-2-1, 9:03:07
 */
public class MainUI extends JFrame{
    private JSplitPane sp1 = new JSplitPane();
    private JSplitPane sp2 = new JSplitPane();
    private JMenuBar menuBar = new JMenuBar();
    private JMenu copyrightMenu = new JMenu();
    private StatusBar statusBar=new StatusBar();
    private JList chooseList = new JList();
    private DefaultListModel chooseModel = new DefaultListModel();
    private static MainUI instance;
    public static MainUI getInstance(){
        if(instance == null){
            instance = new MainUI();
        }
        return instance;
    }
    private MainUI(){
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new Dimension(1024, 768));
//        getContentPane().setLayout(new GridLayout());
        getContentPane().add(sp1);
        sp1.setDividerLocation(280);
        sp2.setDividerLocation(500);
        setJMenuBar(menuBar);
        copyrightMenu.setText("copyright");
        menuBar.add(copyrightMenu);
        setTitle(GV.titleName);
        initChooseModel();
        getContentPane().add(statusBar, java.awt.BorderLayout.PAGE_END);
        chooseList.setBackground(new Color(225,255,255));
        try {
            setIconImage(ImageIO.read(new File("src\\projForWen\\wen.jpg")));
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        
        /*----------------左边----------------*/
        sp1.setLeftComponent(chooseList);
        chooseList.setModel(chooseModel);
        chooseList.setCellRenderer(new ListView());
        
        /*----------------右边----------------*/
        sp1.setRightComponent(sp2);
        sp2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        JScrollPane viewPane = new JScrollPane();
        JTextPane infoPane = new JTextPane();
        sp2.setTopComponent(viewPane);
        sp2.setBottomComponent(infoPane);
        
        pack();
    }
    
    private void initChooseModel(){
        ListIcon item1 = new ListIcon("src\\projForWen\\mh.jpg", "雯雯的漫画");
        ListIcon item2 = new ListIcon("src\\projForWen\\by.jpg", "毕业那年");
        ListIcon item3 = new ListIcon("src\\projForWen\\xy.jpg", "夕阳无限");
        chooseModel.addElement(item1);
        chooseModel.addElement(item2);
        chooseModel.addElement(item3);
    }
    
}
